package com.example.clock;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class LongClickDialog extends Dialog {
    private TextView title;
    private TextView tag1;
    private TextView tag2;
    private onItemSelectedListener listener;

    public void setListener(onItemSelectedListener listener) {
        this.listener = listener;
    }

    public LongClickDialog(@NonNull Context context) {
        super(context);
    }

    public LongClickDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected LongClickDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.long_click_item);


        title = (TextView) findViewById(R.id.title);
        tag1 = (TextView) findViewById(R.id.tag1);
        tag2 = (TextView) findViewById(R.id.tag2);

        title.setText("选择");
        tag1.setText("更改数据");
        tag2.setText("删除数据");
        tag1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.onChangeData();
                }
            }
        });
        tag2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.onDeleteData();
                }
            }
        });

    }

    public interface onItemSelectedListener{
        void onChangeData();
        void onDeleteData();
    }
}
